<?php /*a:3:{s:47:"E:\phpthink\work\tp\view\admins\lend\index.html";i:1652877656;s:18:"common/header.html";i:1652878502;s:18:"common/footer.html";i:1652023572;}*/ ?>


<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>图书馆管理系统</title>
  <!-- 引入 layui.css -->
  <link rel="stylesheet" href="http://127.0.0.1:8000/layui/css/layui.css">
  <link rel="stylesheet" href="http://127.0.0.1:8000/layer/layer.js">
  <!-- 引入 layui.js -->
  <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
  <link rel="stylesheet" href="http://127.0.0.1:8000/static/index.css">
  <script src="http://127.0.0.1:8000/layui/layui.js"></script>
  <link href="http://127.0.0.1:8000/bootstrap-3.4.1-dist/css/bootstrap.css" rel="stylesheet">
  <script src="http://127.0.0.1:8000/jquery-3.6.0.min.js"></script>
  <script src="http://127.0.0.1:8000/bootstrap-3.4.1-dist/js/bootstrap.js"></script>
  <script src="http://127.0.0.1:8000/echarts.min.js"></script>
</head>
<body>
<div class="layui-layout layui-layout-admin">
  <div class="layui-header">
    <div class="layui-logo layui-hide-xs layui-bg-black">图书管理系统</div>
    <ul class="layui-nav layui-layout-right">
      <li class="layui-nav-item"><a href="#"><?php echo session("username"); ?>&nbsp;已登录</a></li>
      <li class="layui-nav-item layui-hide layui-show-md-inline-block">
        <a href="javascript:;">
          更多操作
        </a>
        <dl class="layui-nav-child">
          <dd><a href="/signOut">退出登录</a></dd>
        </dl>
      </li>
    </ul>
  </div>

  <div class="layui-side layui-bg-black">
    <div class="layui-side-scroll">
      <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
      <ul class="layui-nav layui-nav-tree" lay-filter="test">
        <li class="layui-nav-item layui-nav-itemed">
          <a class="" href="javascript:;">账号管理</a>
          <dl class="layui-nav-child">
            <dd><a href="/admins/admin">账号列表</a></dd>
          </dl>
        </li>
        <li class="layui-nav-item">
          <a href="javascript:;">权限管理</a>
          <dl class="layui-nav-child">
            <dd><a href="/admins/rights">权限管理</a></dd>
          </dl>
        </li>
        <li class="layui-nav-item">
          <a href="javascript:;">图书管理</a>
          <dl class="layui-nav-child">
            <dd><a href="/admins/booklist">图书列表</a></dd>
            <dd><a href="/admins/category">图书分类</a></dd>
            <dd><a href="/admins/publisher">供应商</a></dd>
          </dl>
        </li>
        <li class="layui-nav-item">
          <a href="javascript:;">借阅管理</a>
          <dl class="layui-nav-child">
            <dd><a href="/admins/lend">超时列表</a></dd>
          </dl>
        </li>
        <li class="layui-nav-item">
          <a href="javascript:;">数据统计</a>
          <dl class="layui-nav-child">
            <dd><a href="/admins/reports">数据报表</a></dd>
          </dl>
        </li>
      </ul>
    </div>
  </div>
<!-- 内容主体区域 -->
<div class="layui-body">
    <!--        <div style="padding: 15px;"><h1 style="font-weight: 700">欢迎界面</h1></div>-->
    <div id="user_container" style="padding: 15px;">
        <!--            面包屑导航-->
        <span class="layui-breadcrumb">
              <a href="#" style="font-weight: 700;color: #000!important;">首页</a>
              <a href="#" style="font-weight: 700;color: #000!important;">图书管理</a>
              <a href="" >权限管理</a>
            </span>
        <div class="layui-row layui-col-space15" style="margin-top: 15px">
            <div class="layui-col-md12">
                <div class="layui-panel" style="padding: 20px">
                    <table lay-filter="bookListTable"  class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>
                </div>
            </div>
        </div>
    </div>
</div>
</div>


<!--状态模板字符-->
<script type="text/html" id="switchOnOff">
    <input type="checkbox" mid={{d.id}}  name="isManager"
           lay-skin="switch"
           {{d.state===1?"checked":''}}
           lay-filter="switchTest"
    >
</script>

<script>
    document.querySelector('.layui-nav-itemed').classList.remove('layui-nav-itemed');
    $('a[href$=lend]').parent()[0].classList.add('layui-this');
    $('a[href$=lend]').parent().parent().parent()[0].classList.add('layui-nav-itemed');


    console.log((new Date(1652871940904)))
    var formhorizontal  = document.querySelector('.form-horizontal')
    var sureBtn = document.getElementById('sureBtn');
    layui.use(['form', 'table'], function () {
        var $ = layui.jquery,
            form = layui.form,
            table = layui.table;

        // 更新用户状态
        form.on('switch(switchTest)', async function(obj){
            var id = $(this).attr('mid');
            // console.info('id:' + id);
            var isManager = obj.elem.checked?"1":"0";
            // console.info('isManager:' + isManager);
            const {data:res} = await axios.post('/admins/lend/editState',{
                state:isManager,
                id:id})

            if(res.state!==200) {
                return layer.msg(res.message,
                    {icon: 0, time: 1000})
            }
            layer.msg('更改成功', {
                icon: 1,
                time: 1500
            })
        })

        // 渲染表格
        table.render({
            elem: '#currentTableId',
            where:{
                time:(new Date()).valueOf()
            }
            ,limit:20
            ,url: "<?php echo url('/admins/lend/article'); ?>" //数据接口
            ,page: true //开启分页
            ,limits:[10,20,30]
            ,skin: 'row,line'
            ,id:'bookTable'
            ,cols: [[ //表头
                // {type: "checkbox", },
                {field: 'id',align:"center", title: 'ID'},
                {field: 'name',align:"center", title: '用户名'},
                {field: 'phone',align:"center", title: '联系方式'},
                {field: 'state', align:"center",title: '状态',  toolbar: '#switchOnOff'
                },
            ]],

        });


    });




</script>



</body>

</html>
